#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    int oddoneven = 0, evenonodd = 0;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      if (x % 2 == 0 && i % 2 != 0)
        evenonodd++;
      else if (x % 2 != 0 && i % 2 == 0)
        oddoneven++;
    }
    // cout << cnt << endl;
    int ans = -1;
    if (evenonodd == oddoneven) ans = evenonodd;
    cout << ans << endl;
  }
}
